﻿<%@ Control Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Import Namespace="ArbolandiaBL" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
    public delegate void ReloadGridFromUsr();
    public event ReloadGridFromUsr reloadgrid;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!ArbolandiaBL.Security.ValidLogin())
        {
            X.AddScript("this.parent.LogOut();");

        }
        if (!X.IsAjaxRequest)
        {
            InitForm();
            dpfImageSizeCat.Text = ConstantsBL.SIZE_IMAGE_PRODUCT_BIG_TITLE;
        }
    }
    protected void InitForm()
    {
        pnlProductInfoTab.Reset();
        pnlProductDetailInfo.Reset();
        pnlProductComplements.Reset();
        pnlProductPreferences.Reset();
        pnlProductImages.Reset();
        txtOrderPreference.SetValue("0");
        this.storeProductComplement.DataSource = new Service().GetAllProducts();
        this.storeProductComplement.DataBind();
        storeGridProductsComplement.DataSource = new List<object>();
        storeProductDetail.DataSource = new List<object>();
        storeProductImages.DataSource = new List<object>();
        storeGridProductsComplement.DataBind();
        storeProductDetail.DataBind();
        storeProductImages.DataBind();
        txtOrderPreference.SetValue("0");
        this.storeColor.DataSource = new Service().GetColors();
        this.storeColor.DataBind();
        this.storecmbProductPreference.DataSource = new Service().GetPreferences();
        this.storecmbProductPreference.DataBind();
        var list = new Service().GetCategorys();
        LoadCategory(list);


    }
    protected void LoadCategory(List<Product_Category> list)
    {
        var data = new List<object>();
        foreach (var item in list)
        {
            //data.Add(new { Id = item.Id.ToString(), Name = item.Name });
            data.Add(new object[] { item.Id.ToString(), item.Name });
        }
        this.CategoryStore.DataSource = data;
        this.CategoryStore.DataBind();

    }
    public Store GridStore { get; set; }

    public void Show()
    {
        this.ProductDetailsWindow.Show();
    }

    public void SetProduct(Product_Product product)
    {
        if (product != null)
        {
            string[] floracionArray = product.MesesFloracion.Split(new char[] { ',' });
            string[] frutosArray = product.MesesFruto.Split(new char[] { ',' });

            foreach (var item in floracionArray)
            {
                multiMesesFloracion.SelectedItems.Add(new Ext.Net.ListItem() { Value = item });
            }

            foreach (var item in frutosArray)
            {
                multiMesesFruto.SelectedItems.Add(new Ext.Net.ListItem() { Value = item });
            }
            multiMesesFloracion.UpdateSelectedItems();
            multiMesesFruto.UpdateSelectedItems();
            multiMesesFloracion.Render();
            multiMesesFruto.Render();
            pnlProductInfoTab.SetValues(product);
            ReloadGridDetail(product.Id);
            ReloadGridProducImages(product.Id);
            ReloadGridDetail(product.Id);
            ReloadGridProductPreferences(product.Id);
            ReloadGridComplements(product.Id);
            LoadCategory(new Service().GetCategorys());
            ReloadCombosSubcategory(product.Id);
        }
        else
        {
            InitForm();
        }

    }
    protected void ReloadCombosSubcategory(Int32 id)
    {
        //load combos
        var subcategory = new Service().GetSubcateforyForProduct(id);
        if (subcategory != null && subcategory.Id > 0)
        {
            this.ComboBox2.SelectedItems.Clear();
            this.ComboBox1.SelectedItems.Clear();

            this.ComboBox1.SelectedItems.Add(new Ext.Net.ListItem()
            {
                Value = subcategory.Product_CategoryId.ToString()
            });
            CitiesRefresh(null, null);

            this.ComboBox2.SelectedItems.Add(new Ext.Net.ListItem()
            {
                Value = subcategory.Id.ToString()
            });
            this.ComboBox1.UpdateSelectedItems();
            this.ComboBox2.UpdateSelectedItems();
            //hiddenCategory.Value = subcategory.Product_CategoryId.ToString();
            //hiddenSubCategory.Value = subcategory.Id.ToString();
        }
        //X.AddScript("OnLoad();");

    }
    protected void ReloadGridDetail(Int32 id)
    {
        storeProductDetail.DataSource = new Service().GetProductDetailAll(id);
        storeProductDetail.DataBind();
    }

    protected void SaveProduct(object sender, DirectEventArgs e)
    {
        //NorthwindDataContext db = new NorthwindDataContext();
        int id;
        int.TryParse(e.ExtraParams["id"], out id);

        Product_Product p = new Product_Product();
        p.Id = id;
        p.AlturaPlanta = txtAlturaPlanta.Text;
        p.Color = 0;
        p.DescripcionCorta = txtDescripcionCorta.Text;
        p.DescripcionLarga = txtDescripcionLarga.Text;
        p.Detalles = heditDetalles.Text;
        p.IsDestacado = (bool)chkIsDestacado.Value;
        p.IsOferta = (bool)chkIsOferta.Value;
        p.ShowAtHome = (bool)chkShowAtHome.Value;
        p.Mantenimiento = heditMantenimiento.Text;
        Int32 color = 0;
        if (cmbColor.SelectedItems.Count() > 0)
        {
            Int32.TryParse(cmbColor.SelectedItem.Value, out color);
        }
        p.Color = (short)color;
        StringBuilder sb1 = new StringBuilder(256);
        StringBuilder sb = new StringBuilder(256);

        foreach (Ext.Net.ListItem item in multiMesesFloracion.SelectedItems)
        {
            sb.Append("," + item.Value);
        }
        if (sb.ToString().StartsWith(",")) { sb.Remove(0, 1); }

        foreach (Ext.Net.ListItem item in multiMesesFruto.SelectedItems)
        {
            sb1.Append("," + item.Value);
        }
        if (sb1.ToString().StartsWith(",")) { sb1.Remove(0, 1); }
        p.MesesFloracion = sb.ToString();
        p.MesesFruto = sb1.ToString();
        p.Nombre = txtName.Text;
        p.NombreCientifico = txtNombreCientifico.Text;
        p.Plantación = heditPlantación.Text;
        var session = (ObSession)Session["ObSession"];
        var idprod = new Service().InsertUpdateProduct(p, session);

        int subcategory = 0;
        if (this.ComboBox2.SelectedItem != null)
        {
            Int32.TryParse(this.ComboBox2.SelectedItem.Value, out subcategory);
        }
        new Service().InsertUpdateProductOnSubcategory(new Product_SubCategoryGroup()
        {
            Product_ProductId = idprod,
            Product_SubCategoryId = subcategory
        });
        ReloadGridParent();
        this.ProductDetailsWindow.Hide();

        //if (id == 0)
        //{

        //}
        //else
        //{
        //    var record = this.GridStore.GetById(id);
        //    this.ProductDetailsWindow.Hide();
        //    pnlProductInfoTab.UpdateRecord(record);
        //    record.Commit();
        //}

    }

    protected void ReloadGridParent()
    {
        reloadgrid();
    }
    protected void UploadClickProductImages(object sender, DirectEventArgs e)
    {

        string tpl = "Uploaded file: {0}<br/>Size: {1} bytes";
        if (this.uploadFieldProductImages.HasFile &&
            (this.uploadFieldProductImages.PostedFile.FileName.ToLower().Contains(".png") ||
             this.uploadFieldProductImages.PostedFile.FileName.ToLower().Contains(".jpg") ||
            this.uploadFieldProductImages.PostedFile.FileName.ToLower().Contains(".jpeg"))
            )
        {
            Int32 productid; Int32.TryParse(e.ExtraParams["id"], out productid);
            Int32 maximages = 0;
            Int32.TryParse(System.Configuration.ConfigurationManager.AppSettings["maximages"], out maximages);
            Int32 actualimages = new Service().GetCountImagesProduct(productid);

            if (productid > 0 && (actualimages < maximages))
            {
                Guid pictureGuidSmall = Guid.NewGuid(); Guid pictureGuidBig = Guid.NewGuid();
                string extension = Path.GetExtension(this.uploadFieldProductImages.PostedFile.FileName);
                string pathfile = System.Configuration.ConfigurationManager.AppSettings["imagesfolder"];
                string filenameSmall = pictureGuidSmall + extension;
                string filenameBig = pictureGuidBig + extension;
                string fullPathSmallpathfile = Server.MapPath(@"~" + @"\" + pathfile + @"\" + filenameSmall);
                string fullPathBigpathfile = Server.MapPath(@"~" + @"\" + pathfile + @"\" + filenameBig);

                new Service().SaveRezizeImage(fullPathSmallpathfile, uploadFieldProductImages.PostedFile.InputStream, ConstantsBL.SIZE_IMAGE_PRODUCT_SMALL_HEIGHT, ConstantsBL.SIZE_IMAGE_PRODUCT_SMALL_WIDTH);
                new Service().SaveRezizeImage(fullPathBigpathfile, uploadFieldProductImages.PostedFile.InputStream, ConstantsBL.SIZE_IMAGE_PRODUCT_BIG_HEIGHT, ConstantsBL.SIZE_IMAGE_PRODUCT_BIG_WIDTH);

                //Save Guid
                Picture picSmall = new Picture()
                {
                    IsFullSize = false,
                    Url = "http://hostimages/" + System.Configuration.ConfigurationManager.AppSettings["imagesfolder"] + "/" + filenameSmall,
                    ToolTip = "",
                    MimeType = "",
                    LinkUrl = "",
                    IsEnabled = true,
                    GuidId = pictureGuidSmall,
                    GroupdId = 0
                };

                Picture picBig = new Picture()
                {
                    IsFullSize = true,
                    Url = "http://hostimages/" + System.Configuration.ConfigurationManager.AppSettings["imagesfolder"] + "/" + filenameBig,
                    ToolTip = "",
                    MimeType = "",
                    LinkUrl = "",
                    IsEnabled = true,
                    GuidId = pictureGuidBig,
                    GroupdId = 0
                };
                short order = 0; string shortVal; shortVal = txtOrderProductImages.Value != null ? txtOrderProductImages.Value.ToString() : "0";
                short.TryParse(shortVal, out order);
                Product_ProductPictures pp = new Product_ProductPictures()
                {
                    Order = order,
                    PictureFullSizeGuidId = pictureGuidBig,
                    PictureThumbnailGuidId = pictureGuidSmall,
                    Product_ProductId = productid
                };
                new Service().InsertProductPicture(picSmall, picBig, pp);
                pnlProductImages.Reset();
                ReloadGridProducImages(productid);
                ReloadGridParent();

                X.Msg.Show(new MessageBoxConfig
                {
                    Buttons = MessageBox.Button.OK,
                    Icon = MessageBox.Icon.INFO,
                    Title = "Exito",
                    Message = string.Format(tpl, this.uploadFieldProductImages.PostedFile.FileName, this.uploadFieldProductImages.PostedFile.ContentLength)
                });
            }
            else
            {

                X.Msg.Show(new MessageBoxConfig
                {
                    Buttons = MessageBox.Button.OK,
                    Icon = MessageBox.Icon.WARNING,
                    Title = "Alerta",
                    Message = "Favor de Guardar Primero Datos principales del Producto"
                });
                return;
            }


        }
        else
        {
            X.Msg.Show(new MessageBoxConfig
            {
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.ERROR,
                Title = "Error",
                Message = "No se pudo cargar el archivo"
            });
        }
    }
    protected void ReloadGridProducImages(Int32 id)
    {
        storeProductImages.DataSource = new Service().GetProductPictures(id);
        storeProductImages.DataBind();
    }
    protected void btnDeleteProductImages_Click(object sender, DirectEventArgs e)
    {
        int iddetail, id;
        string json = e.ExtraParams["idValues"];

        if (string.IsNullOrEmpty(json))
        {
            X.Msg.Show(new MessageBoxConfig
            {
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.WARNING,
                Title = "Alerta",
                Message = "Favor de Seleccionar un registro"
            });
            return;
        }
        Dictionary<string, string>[] valuesdic = JSON.Deserialize<Dictionary<string, string>[]>(json);
        string sid = "";
        foreach (Dictionary<string, string> row in valuesdic)
        {
            sid = row["Id"];
        }

        Int32.TryParse(sid, out iddetail); Int32.TryParse(e.ExtraParams["id"], out id);
        if (id <= 0)
        {
            X.Msg.Show(new MessageBoxConfig
            {
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.WARNING,
                Title = "Alerta",
                Message = "Favor de Seleccionar un registro"
            });
            return;
        }

        new Service().DeleteProductPicture(iddetail);
        pnlProductImages.Reset();
        ReloadGridProducImages(id);
    }

    protected void btnDeleteProductDetail_Click(object sender, DirectEventArgs e)
    {
        int iddetail, id;
        string json = e.ExtraParams["idValues"];

        if (string.IsNullOrEmpty(json))
        {
            X.Msg.Show(new MessageBoxConfig
            {
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.WARNING,
                Title = "Alerta",
                Message = "Favor de Seleccionar un registro"
            });
            return;
        }
        Dictionary<string, string>[] valuesdic = JSON.Deserialize<Dictionary<string, string>[]>(json);
        string sid = "";
        foreach (Dictionary<string, string> row in valuesdic)
        {
            sid = row["Id"];
        }

        Int32.TryParse(sid, out iddetail); Int32.TryParse(e.ExtraParams["id"], out id);
        if (id <= 0)
        {
            X.Msg.Show(new MessageBoxConfig
            {
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.WARNING,
                Title = "Alerta",
                Message = "Favor de Seleccionar un registro"
            });
            return;
        }

        new Service().DeleteProductDetail(iddetail, id);
        ReloadGridDetail(id);
        ReloadGridParent();
    }
    protected void AddDetailClick(object sender, DirectEventArgs e)
    {
        Int32 id, stock; Decimal precio, preciopromo;
        Decimal.TryParse(txtPrecioDetail.Text, out precio);
        Decimal.TryParse(txtPrecioPromocionDetail.Text, out preciopromo);
        Int32.TryParse(txtStockDetail.Text, out stock);

        Int32.TryParse(e.ExtraParams["id"], out id);
        if (id > 0)
        {
            Product_ProductDetail pd = new Product_ProductDetail();
            pd.CodigoProducto = txtCodigoProductoDetail.Text;
            pd.Descripcion = txtDescripcionDetail.Text;
            pd.GuidId = Guid.NewGuid();
            pd.IsAcompanamiento = (bool)chkIsAcompanamientoDetail.Value;
            pd.Precio = precio;
            pd.PrecioPromocion = preciopromo;
            pd.Product_ProductId = id;
            pd.Stock = stock;

            new Service().InsertUpdateProductDetail(pd);
            pnlProductDetailInfo.Reset();
            ReloadGridDetail(id);
            ReloadGridParent();

        }
        else
        {

            X.Msg.Show(new MessageBoxConfig
            {
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.WARNING,
                Title = "Alerta",
                Message = "Favor de Guardar Primero Datos principales del Producto"
            });
            return;
        }

    }
    protected void btnAddProductComplement_Click(object sender, DirectEventArgs e)
    {
        var addObj = new Product_ProductComplement();
        Int32 productrefid, productid;
        if (cmbProductComplements.SelectedItem != null) { Int32.TryParse(cmbProductComplements.SelectedItem.Value, out productrefid); }
        else { productrefid = 0; }
        Int32.TryParse(e.ExtraParams["id"], out productid);
        if (productid > 0)
        {
            if (productid != productrefid)
            {
                addObj.Product_ProductId = productid;
                addObj.Product_ProductIdRef = productrefid;
                new Service().InsertUpdateComplements(addObj);
                pnlProductComplements.Reset();
                ReloadGridComplements(productid);

            }
            else
            {
                X.Msg.Show(new MessageBoxConfig
                {
                    Buttons = MessageBox.Button.OK,
                    Icon = MessageBox.Icon.WARNING,
                    Title = "Alerta",
                    Message = "No se puede ser complemento de si mismo."
                });
                return;
            }

        }
        else
        {

            X.Msg.Show(new MessageBoxConfig
            {
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.WARNING,
                Title = "Alerta",
                Message = "Favor de Guardar Primero Datos principales del Producto"
            });
            return;
        }
    }

    protected void ReloadGridComplements(Int32 id)
    {
        storeGridProductsComplement.DataSource = new Service().GetComplements(id, false);
        storeGridProductsComplement.DataBind();
    }

    protected void btnDeleteProductComplement_Click(object sender, DirectEventArgs e)
    {
        int idcomplement, id;
        string json = e.ExtraParams["idValues"];

        if (string.IsNullOrEmpty(json))
        {
            X.Msg.Show(new MessageBoxConfig
            {
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.WARNING,
                Title = "Alerta",
                Message = "Favor de Seleccionar un registro"
            });
            return;
        }
        Dictionary<string, string>[] valuesdic = JSON.Deserialize<Dictionary<string, string>[]>(json);
        string sid = "";
        foreach (Dictionary<string, string> row in valuesdic)
        {
            sid = row["Id"];
        }

        Int32.TryParse(sid, out idcomplement); Int32.TryParse(e.ExtraParams["id"], out id);
        if (idcomplement <= 0)
        {
            X.Msg.Show(new MessageBoxConfig
            {
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.WARNING,
                Title = "Alerta",
                Message = "Favor de Seleccionar un registro"
            });
            return;
        }

        new Service().DeleteComplements(idcomplement);
        ReloadGridComplements(id);
    }
    protected void cmbProductPreferences_selectedChange(object sender, DirectEventArgs e)
    {
        Int32 selectedID = 0;

        if (cmbProductPreferences.SelectedItem != null) { Int32.TryParse(cmbProductPreferences.SelectedItem.Value, out selectedID); }
        else { selectedID = 0; }

        var pref = new Service().GetPreferenceId(selectedID);
        txtNamePreference.Text = pref.Name;
        txtDefaultDescriptionPreference.Text = pref.DefaultDescription;
        if ((bool)pref.IsOpenText)
        {
            txtDefaultDescriptionPreference.Disabled = false;
        }
        else
        {
            txtDefaultDescriptionPreference.Disabled = true;
        }
        //if (pref.Options != null && pref.Options != "")
        //{
        //    List<object> listsource = new List<object>();
        //    var list = Ext.Net.JSON.Deserialize<List<string>>(pref.Options);
        //    foreach (var item in list)
        //    {
        //        listsource.Add(new object[] { item != null ? item.ToString() : "" });
        //    }
        //    storeOptionsDescriptPreference.DataSource = listsource;
        //    storeOptionsDescriptPreference.DataBind();
        //}
    }
    protected void btnDeleteProductPreference_Click(object sender, DirectEventArgs e)
    {
        int iddetail, id;
        string json = e.ExtraParams["idValues"];

        if (string.IsNullOrEmpty(json))
        {
            X.Msg.Show(new MessageBoxConfig
            {
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.WARNING,
                Title = "Alerta",
                Message = "Favor de Seleccionar un registro"
            });
            return;
        }
        Dictionary<string, string>[] valuesdic = JSON.Deserialize<Dictionary<string, string>[]>(json);
        string sid = "";
        foreach (Dictionary<string, string> row in valuesdic)
        {
            sid = row["Id"];
        }

        Int32.TryParse(sid, out iddetail); Int32.TryParse(e.ExtraParams["id"], out id);
        if (iddetail <= 0)
        {
            X.Msg.Show(new MessageBoxConfig
            {
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.WARNING,
                Title = "Alerta",
                Message = "Favor de Seleccionar un registro"
            });
            return;
        }

        new Service().DeleteProductPreferences(iddetail);
        ReloadGridProductPreferences(id);

    }
    protected void btnAddProductPreference_Click(object sender, DirectEventArgs e)
    {
        var addObj = new Product_ProductPreferenceGroup();
        Int32 preferenceid, productid;
        if (cmbProductPreferences.SelectedItem != null) { Int32.TryParse(cmbProductPreferences.SelectedItem.Value, out preferenceid); }
        else { preferenceid = 0; }
        Int32.TryParse(e.ExtraParams["id"], out productid);
        if (productid > 0 && preferenceid > 0)
        {
            var pref = new Service().GetPreferenceId(preferenceid);
            addObj.Product_PreferenceId = preferenceid;
            addObj.Product_ProductId = productid;
            addObj.Description = txtDefaultDescriptionPreference.Text;
            addObj.Name = pref.Name;
            addObj.Order = short.Parse(txtOrderPreference.Value.ToString());
            addObj.PictureGuidId = pref.PictureGuidId;

            new Service().InsertUpdateProductPreferences(addObj);
            pnlProductPreferences.Reset();
            ReloadGridProductPreferences(productid);
        }
        else
        {

            X.Msg.Show(new MessageBoxConfig
            {
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.WARNING,
                Title = "Alerta",
                Message = "Favor de Guardar Primero Datos principales del Producto"
            });
            return;
        }
    }
    protected void ReloadGridProductPreferences(Int32 id)
    {
        storeProductPreference.DataSource = new Service().GetProductPreferences(id);
        storeProductPreference.DataBind();
    }

    protected void CitiesRefresh(object sender, StoreReadDataEventArgs e)
    {

        int category = 0;
        if (this.ComboBox1.SelectedItem != null)
        {
            Int32.TryParse(this.ComboBox1.SelectedItem.Value, out category);
        }
        var list = new Service().GetSubcategorys(category);
        var data = new List<object>();
        foreach (var item in list)
        {
            //data.Add(new { Id = item.Id.ToString(), Name = item.Name });
            data.Add(new { Id = item.Id.ToString(), Name = item.Name });
        }

        this.CitiesStore.DataSource = data;
        this.CitiesStore.DataBind();
    }
   
</script>
<script type="text/javascript">
    
</script>
<ext:Window ID="ProductDetailsWindow" runat="server" Icon="Group" Title="Producto Detalle"
    Width="750" MinHeight="450" AutoShow="false" Modal="true" Hidden="true" Flex="1"
    AutoScroll="true" Maximized="true">
    <Items>
        <ext:TabPanel ID="TabPanel1" runat="server" ActiveTabIndex="0" Border="false" DeferredRender="false">
            <Items>
                <ext:FormPanel ID="pnlProductInfoTab" runat="server" Title="Informacion" Icon="ChartOrganisation"
                    DefaultAnchor="100%" BodyPadding="5" Margin="5" MonitorValid="true">
                    <TopBar>
                        <ext:Toolbar ID="toolbProductInfoDetail" runat="server">
                            <Items>
                                <ext:Button ID="SaveButton" runat="server" Text="Save" Icon="Disk">
                                    <DirectEvents>
                                        <Click OnEvent="SaveProduct" Failure="Ext.MessageBox.alert('Saving failed', 'Error during ajax event');">
                                            <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{ProductDetailsWindow}.body}" />
                                            <ExtraParams>
                                                <ext:Parameter Name="id" Value="#{IdProduct}.getValue()" Mode="Raw" />
                                            </ExtraParams>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <Items>
                        <ext:TextField ID="IdProduct" runat="server" FieldLabel="ID" Disabled="true" Name="Id" />
                        <ext:TextField ID="txtName" runat="server" FieldLabel="Nombre" Name="Nombre" />
                        <ext:TextField ID="txtNombreCientifico" runat="server" FieldLabel="NombreCientifico"
                            Name="NombreCientifico" />
                        <ext:TextField ID="txtDescripcionCorta" runat="server" FieldLabel="DescripcionCorta"
                            Name="DescripcionCorta" MaxLength="196" MaxLengthText="196" />
                        <ext:TextArea ID="txtDescripcionLarga" runat="server" FieldLabel="DescripcionLarga"
                            Name="DescripcionLarga" Height="80" MaxLength="630" MaxLengthText="630" />
                        <%--<ext:TextField ID="txtAlturaPlanta" runat="server" FieldLabel="AlturaPlanta" Name="AlturaPlanta" />--%>
                        <ext:NumberField ID="txtAlturaPlanta" runat="server" FieldLabel="AlturaPlanta (mts)"
                            Name="AlturaPlanta" />
                        <ext:FieldContainer ID="FieldContainer7" runat="server" FieldLabel="Categoria / Subcategoria"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:ComboBox ID="ComboBox1" runat="server" Editable="false" SelectOnFocus="true"
                                    EmptyText="Categoria" QueryMode="Local" ValueField="Id" DisplayField="Name" ClientIDMode="Static">
                                    <Listeners>
                                        <Select Handler="#{ComboBox2}.clearValue(); #{CitiesStore}.reload();">
                                        </Select>
                                    </Listeners>
                                    <Store>
                                        <ext:Store runat="server" ID="CategoryStore">
                                            <Model>
                                                <ext:Model ID="ModelCombo1" runat="server" IDProperty="Id">
                                                    <Fields>
                                                        <ext:ModelField Name="Id" />
                                                        <ext:ModelField Name="Name" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                </ext:ComboBox>
                                <ext:ComboBox ID="ComboBox2" runat="server" TypeAhead="true" QueryMode="Local" ForceSelection="true"
                                    TriggerAction="All" DisplayField="Name" ValueField="Id" EmptyText="Loading..."
                                    Editable="false" ValueNotFoundText="Loading..." ClientIDMode="Static">
                                    <Store>
                                        <ext:Store runat="server" ID="CitiesStore" AutoLoad="false" OnReadData="CitiesRefresh">
                                            <Model>
                                                <ext:Model ID="Model8" runat="server" IDProperty="Id">
                                                    <Fields>
                                                        <ext:ModelField Name="Id" Type="String" Mapping="Id" />
                                                        <ext:ModelField Name="Name" Type="String" Mapping="Name" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                            <Listeners>
                                                <Load Handler="#{ComboBox2}.setValue(#{ComboBox2}.store.getAt(0).get('id'));" />
                                            </Listeners>
                                        </ext:Store>
                                    </Store>
                                </ext:ComboBox>
                            </Items>
                        </ext:FieldContainer>
                        <ext:HtmlEditor runat="server" Height="160" ID="heditPlantación" LabelAlign="Top"
                            Name="Plantación" AutoScroll="true" FieldLabel="Plantacion" />
                        <ext:HtmlEditor runat="server" Height="160" ID="heditMantenimiento" LabelAlign="Top"
                            Name="Mantenimiento" AutoScroll="true" FieldLabel="Mantenimiento" />
                        <ext:HtmlEditor runat="server" Height="160" ID="heditDetalles" LabelAlign="Top" Name="Detalles"
                            AutoScroll="true" FieldLabel="Detalles" />
                        <ext:Checkbox ID="chkIsOferta" runat="server" FieldLabel="Es Oferta" Name="IsOferta" />
                        <ext:Checkbox ID="chkIsDestacado" runat="server" FieldLabel="Es Destacado" Name="IsDestacado" />
                        <ext:Checkbox ID="chkShowAtHome" runat="server" FieldLabel="Mostar Pagina Inicio"
                            Name="ShowAtHome" />
                        <ext:ComboBox ID="cmbColor" runat="server" FieldLabel="Color" Name="Id" AllowBlank="true"
                            DisplayField="Nombre" ValueField="Id" TypeAhead="true" QueryMode="Local" ForceSelection="true"
                            TriggerAction="All" EmptyText="Seleccionar Color..." Width="350">
                            <Store>
                                <ext:Store runat="server" ID="storeColor">
                                    <Model>
                                        <ext:Model ID="Model2" runat="server" IDProperty="Id">
                                            <Fields>
                                                <ext:ModelField Name="Id" />
                                                <ext:ModelField Name="Nombre" />
                                                <ext:ModelField Name="HexColor" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                        </ext:ComboBox>
                        <ext:MultiSelect ID="multiMesesFloracion" runat="server" SubmitText="false" FieldLabel="MesesFloracion">
                            <Items>
                                <ext:ListItem Text="Enero" Value="1" />
                                <ext:ListItem Text="Febrero" Value="2" />
                                <ext:ListItem Text="Marzo" Value="3" />
                                <ext:ListItem Text="Abril" Value="4" />
                                <ext:ListItem Text="Mayo" Value="5" />
                                <ext:ListItem Text="Junio" Value="6" />
                                <ext:ListItem Text="Julio" Value="7" />
                                <ext:ListItem Text="Agosto" Value="8" />
                                <ext:ListItem Text="Septiembre" Value="9" />
                                <ext:ListItem Text="Octubre" Value="10" />
                                <ext:ListItem Text="Noviembre" Value="11" />
                                <ext:ListItem Text="Diciembre" Value="12" />
                            </Items>
                        </ext:MultiSelect>
                        <ext:MultiSelect ID="multiMesesFruto" runat="server" SubmitText="false" FieldLabel="MesesFruto">
                            <Items>
                                <ext:ListItem Text="Enero" Value="1" />
                                <ext:ListItem Text="Febrero" Value="2" />
                                <ext:ListItem Text="Marzo" Value="3" />
                                <ext:ListItem Text="Abril" Value="4" />
                                <ext:ListItem Text="Mayo" Value="5" />
                                <ext:ListItem Text="Junio" Value="6" />
                                <ext:ListItem Text="Julio" Value="7" />
                                <ext:ListItem Text="Agosto" Value="8" />
                                <ext:ListItem Text="Septiembre" Value="9" />
                                <ext:ListItem Text="Octubre" Value="10" />
                                <ext:ListItem Text="Noviembre" Value="11" />
                                <ext:ListItem Text="Diciembre" Value="12" />
                            </Items>
                        </ext:MultiSelect>
                    </Items>
                    <Listeners>
                        <ValidityChange Handler="#{SaveButton}.setDisabled(!valid);" />
                    </Listeners>
                </ext:FormPanel>
                <ext:FormPanel ID="pnlProductDetailInfo" runat="server" Title="Detalle" Icon="ChartOrganisation"
                    DefaultAnchor="100%" BodyPadding="5" Margin="5">
                    <Items>
                        <ext:TextField ID="txtIdDetail" runat="server" FieldLabel="ID" Disabled="true" Name="Id" />
                        <ext:TextField ID="txtPrecioDetail" runat="server" FieldLabel="Precio" Name="Precio" />
                        <ext:TextField ID="txtPrecioPromocionDetail" runat="server" FieldLabel="Precio Promocion"
                            Name="PrecioPromocion" />
                        <ext:TextField ID="txtCodigoProductoDetail" runat="server" FieldLabel="Codigo Producto"
                            Name="CodigoProducto" />
                        <ext:TextField ID="txtDescripcionDetail" runat="server" FieldLabel="Descripcion"
                            Name="Descripcion" />
                        <ext:TextField ID="txtStockDetail" runat="server" FieldLabel="Almacen Stock" Name="Stock" />
                        <ext:Checkbox ID="chkIsAcompanamientoDetail" runat="server" FieldLabel="Es Acompañamiento"
                            Name="IsAcompanamiento" />
                        <ext:FieldContainer ID="fieldcontainer3" runat="server">
                            <Items>
                                <ext:GridPanel ID="gridProductDetail" runat="server" ClientIDMode="Static" AutoScroll="true"
                                    Height="300">
                                    <Store>
                                        <ext:Store ID="storeProductDetail" runat="server">
                                            <Model>
                                                <ext:Model ID="Model5" runat="server" IDProperty="GuidId">
                                                    <Fields>
                                                        <ext:ModelField Name="Id" />
                                                        <ext:ModelField Name="CodigoProducto" />
                                                        <ext:ModelField Name="Descripcion" />
                                                        <ext:ModelField Name="Precio" />
                                                        <ext:ModelField Name="PrecioPromocion" />
                                                        <ext:ModelField Name="Stock" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                    <ColumnModel>
                                        <Columns>
                                            <ext:Column ID="Column2" runat="server" Text="Id" Flex="35" DataIndex="Id" />
                                            <ext:Column ID="Column1" runat="server" Text="CodigoProducto" Flex="35" DataIndex="CodigoProducto" />
                                            <ext:Column ID="Column3" runat="server" Text="Descripcion" Flex="35" DataIndex="Descripcion" />
                                            <ext:Column ID="Column4" runat="server" Text="Precio" Flex="35" DataIndex="Precio" />
                                            <ext:Column ID="Column5" runat="server" Text="PrecioPromocion" Flex="35" DataIndex="PrecioPromocion" />
                                            <ext:Column ID="Column6" runat="server" Text="Inventario" Flex="35" DataIndex="Stock" />
                                        </Columns>
                                    </ColumnModel>
                                    <View>
                                        <ext:GridView ID="GridView2" runat="server" EmptyText="Sin informacion para mostrar" />
                                    </View>
                                    <SelectionModel>
                                        <ext:RowSelectionModel ID="RowSelectionModel2" runat="server" Mode="Single" />
                                    </SelectionModel>
                                    <Listeners>
                                        <%--<SelectionChange Fn="selectionChanged" />--%>
                                    </Listeners>
                                    <Buttons>
                                        <ext:Button ID="btnDeleteProductDetail" runat="server" Text="Eliminar">
                                            <DirectEvents>
                                                <Click OnEvent="btnDeleteProductDetail_Click">
                                                    <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{ProductDetailsWindow}.body}" />
                                                    <ExtraParams>
                                                        <ext:Parameter Name="id" Value="#{IdProduct}.getValue()" Mode="Raw" />
                                                        <ext:Parameter Name="idValues" Value="Ext.encode(#{gridProductDetail}.getRowsValues({selectedOnly : true}))"
                                                            Mode="Raw" />
                                                    </ExtraParams>
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                    </Buttons>
                                </ext:GridPanel>
                            </Items>
                        </ext:FieldContainer>
                    </Items>
                    <TopBar>
                        <ext:Toolbar ID="Toolbar1" runat="server">
                            <Items>
                                <ext:Button ID="btnAddDetail" runat="server" Icon="Add" Text="Add">
                                    <DirectEvents>
                                        <Click OnEvent="AddDetailClick">
                                            <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{ProductDetailsWindow}.body}" />
                                            <ExtraParams>
                                                <ext:Parameter Name="id" Value="#{IdProduct}.getValue()" Mode="Raw" />
                                            </ExtraParams>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                </ext:FormPanel>
                <ext:FormPanel ID="pnlProductComplements" runat="server" Title="Productos Complemento"
                    Icon="LayoutContent" DefaultAnchor="100%" BodyPadding="5" Margin="10">
                    <Items>
                        <ext:FieldSet ID="fsetProductComplementMain" runat="server">
                            <Items>
                                <ext:FieldContainer ID="fieldcontainerAddProductComplement" runat="server" Layout="HBoxLayout">
                                    <Items>
                                        <ext:ComboBox ID="cmbProductComplements" runat="server" FieldLabel="Producto" Name="cmbProductComplements"
                                            AllowBlank="true" DisplayField="Name" ValueField="Id" TypeAhead="true" QueryMode="Local"
                                            ForceSelection="true" TriggerAction="All" EmptyText="Seleccionar producto..."
                                            Width="350">
                                            <Store>
                                                <ext:Store runat="server" ID="storeProductComplement">
                                                    <Model>
                                                        <ext:Model ID="Model1" runat="server" IDProperty="Id">
                                                            <Fields>
                                                                <ext:ModelField Name="Id" />
                                                                <ext:ModelField Name="Name" />
                                                                <ext:ModelField Name="url" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                        </ext:ComboBox>
                                        <ext:ToolbarSeparator ID="tblSeparateComplement" runat="server">
                                        </ext:ToolbarSeparator>
                                        <ext:Button ID="btnAddProductComplement" runat="server" Text="Agregar">
                                            <DirectEvents>
                                                <Click OnEvent="btnAddProductComplement_Click">
                                                    <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{ProductDetailsWindow}.body}" />
                                                    <ExtraParams>
                                                        <ext:Parameter Name="id" Value="#{IdProduct}.getValue()" Mode="Raw" />
                                                    </ExtraParams>
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                    </Items>
                                </ext:FieldContainer>
                                <ext:FieldContainer ID="fieldcontainer1" runat="server">
                                    <Items>
                                        <ext:GridPanel ID="gridProductsComplement" runat="server" ClientIDMode="Static" AutoScroll="true"
                                            Height="300">
                                            <Store>
                                                <ext:Store ID="storeGridProductsComplement" runat="server">
                                                    <Model>
                                                        <ext:Model ID="Model3" runat="server" IDProperty="Id">
                                                            <Fields>
                                                                <ext:ModelField Name="Id" />
                                                                <ext:ModelField Name="Name" />
                                                                <ext:ModelField Name="IdRef" />
                                                                <ext:ModelField Name="url" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                            <ColumnModel>
                                                <Columns>
                                                    <ext:TemplateColumn ID="TemplateColumn1" runat="server" Text="Imagen" Flex="15" DataIndex="url"
                                                        TemplateString='<img style="width:60px;height:45px;" src="{url}" />' />
                                                    <ext:Column ID="Column7" runat="server" Text="Nombre" Flex="35" DataIndex="Name" />
                                                </Columns>
                                            </ColumnModel>
                                            <View>
                                                <ext:GridView ID="GridView1" runat="server" EmptyText="Sin registros para mostrar" />
                                            </View>
                                            <SelectionModel>
                                                <ext:RowSelectionModel ID="RowSelectionModelProductComplements" runat="server" Mode="Single" />
                                            </SelectionModel>
                                            <Buttons>
                                                <ext:Button ID="btnDeleteProductComplement" runat="server" Text="Eliminar">
                                                    <DirectEvents>
                                                        <Click OnEvent="btnDeleteProductComplement_Click">
                                                            <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{ProductDetailsWindow}.body}" />
                                                            <ExtraParams>
                                                                <ext:Parameter Name="id" Value="#{IdProduct}.getValue()" Mode="Raw" />
                                                                <ext:Parameter Name="idValues" Value="Ext.encode(#{gridProductsComplement}.getRowsValues({selectedOnly : true}))"
                                                                    Mode="Raw" />
                                                            </ExtraParams>
                                                        </Click>
                                                    </DirectEvents>
                                                </ext:Button>
                                            </Buttons>
                                        </ext:GridPanel>
                                    </Items>
                                </ext:FieldContainer>
                            </Items>
                        </ext:FieldSet>
                    </Items>
                </ext:FormPanel>
                <ext:FormPanel ID="pnlProductPreferences" runat="server" Title="Productos Preferencias"
                    Icon="LayoutContent" DefaultAnchor="100%" BodyPadding="5" Margin="10">
                    <Items>
                        <ext:FieldSet ID="FieldSet1" runat="server">
                            <Items>
                                <ext:FieldContainer ID="fieldcontainer2" runat="server" Layout="HBoxLayout">
                                    <Items>
                                        <ext:ComboBox ID="cmbProductPreferences" runat="server" FieldLabel="Preferencias"
                                            Name="cmbProductPreferences" AllowBlank="true" DisplayField="Name" ValueField="Id"
                                            TypeAhead="true" QueryMode="Local" ForceSelection="true" TriggerAction="All"
                                            EmptyText="Seleccionar Preferencia..." Width="350">
                                            <Store>
                                                <ext:Store runat="server" ID="storecmbProductPreference">
                                                    <Model>
                                                        <ext:Model ID="Model4" runat="server" IDProperty="Id">
                                                            <Fields>
                                                                <ext:ModelField Name="Id" />
                                                                <ext:ModelField Name="Name" />
                                                                <ext:ModelField Name="url" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                            <DirectEvents>
                                                <Select OnEvent="cmbProductPreferences_selectedChange">
                                                </Select>
                                            </DirectEvents>
                                        </ext:ComboBox>
                                    </Items>
                                </ext:FieldContainer>
                                <ext:FieldContainer ID="fieldcontainer8" runat="server">
                                    <Items>
                                        <ext:TextField ID="txtNamePreference" runat="server" FieldLabel="Nombre" Name="txtDefaultDescriptionPreference"
                                            Disabled="true" />
                                        <ext:TextField ID="txtDefaultDescriptionPreference" runat="server" FieldLabel="Descripcion"
                                            Name="txtDefaultDescriptionPreference" />
                                        <ext:NumberField ID="txtOrderPreference" runat="server" FieldLabel="Orden" />
                                        <ext:ToolbarSeparator ID="ToolbarSeparator1" runat="server">
                                        </ext:ToolbarSeparator>
                                        <ext:Button ID="Button1" runat="server" Text="Agregar">
                                            <DirectEvents>
                                                <Click OnEvent="btnAddProductPreference_Click">
                                                    <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{ProductDetailsWindow}.body}" />
                                                    <ExtraParams>
                                                        <ext:Parameter Name="id" Value="#{IdProduct}.getValue()" Mode="Raw" />
                                                    </ExtraParams>
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                    </Items>
                                </ext:FieldContainer>
                                <ext:FieldContainer ID="fieldcontainer4" runat="server">
                                    <Items>
                                        <ext:GridPanel ID="gridProductPreference" runat="server" ClientIDMode="Static" AutoScroll="true"
                                            Height="300" ButtonAlign="Left">
                                            <Store>
                                                <ext:Store ID="storeProductPreference" runat="server">
                                                    <Model>
                                                        <ext:Model ID="Model6" runat="server" IDProperty="Id">
                                                            <Fields>
                                                                <ext:ModelField Name="Id" />
                                                                <ext:ModelField Name="Name" />
                                                                <ext:ModelField Name="Description" />
                                                                <ext:ModelField Name="Order" />
                                                                <ext:ModelField Name="url" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                            <ColumnModel>
                                                <Columns>
                                                    <ext:TemplateColumn ID="TemplateColumn2" runat="server" Text="Imagen" Flex="15" DataIndex="url"
                                                        TemplateString='<img style="width:60px;height:45px;" src="{url}" />' />
                                                    <ext:Column ID="Column8" runat="server" Text="Nombre" Flex="35" DataIndex="Name" />
                                                    <ext:Column ID="Column9" runat="server" Text="Descripcion" Flex="35" DataIndex="Description" />
                                                    <ext:Column ID="Column10" runat="server" Text="Orden" Flex="35" DataIndex="Order" />
                                                </Columns>
                                            </ColumnModel>
                                            <View>
                                                <ext:GridView ID="GridView3" runat="server" EmptyText="Sin registros para mostrar" />
                                            </View>
                                            <SelectionModel>
                                                <ext:RowSelectionModel ID="RowSelectionModelProductPreference" runat="server" Mode="Single" />
                                            </SelectionModel>
                                            <Buttons>
                                                <ext:Button ID="Button2" runat="server" Text="Eliminar">
                                                    <DirectEvents>
                                                        <Click OnEvent="btnDeleteProductPreference_Click">
                                                            <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{ProductDetailsWindow}.body}" />
                                                            <ExtraParams>
                                                                <ext:Parameter Name="id" Value="#{IdProduct}.getValue()" Mode="Raw" />
                                                                <ext:Parameter Name="idValues" Value="Ext.encode(#{gridProductPreference}.getRowsValues({selectedOnly : true}))"
                                                                    Mode="Raw" />
                                                            </ExtraParams>
                                                        </Click>
                                                    </DirectEvents>
                                                </ext:Button>
                                            </Buttons>
                                        </ext:GridPanel>
                                    </Items>
                                </ext:FieldContainer>
                            </Items>
                        </ext:FieldSet>
                    </Items>
                </ext:FormPanel>
                <ext:FormPanel ID="pnlProductImages" runat="server" Title="Imagenes Producto" Icon="LayoutContent"
                    DefaultAnchor="100%" BodyPadding="5">
                    <Items>
                        <ext:FieldSet ID="FieldSet2" runat="server">
                            <Items>
                                <ext:FieldContainer ID="fieldcontainer5" runat="server" Layout="HBoxLayout" Margin="10">
                                    <Items>
                                        <ext:NumberField ID="txtOrderProductImages" runat="server" FieldLabel="Orden" />
                                        <ext:FileUploadField ID="uploadFieldProductImages" runat="server" Width="400" Icon="Attach"
                                            AllowBlank="false" FieldLabel="Ubicacion">
                                        </ext:FileUploadField>
                                        <ext:ToolbarSeparator ID="ToolbarSeparator2" runat="server">
                                        </ext:ToolbarSeparator>
                                        <ext:Button ID="btnUploadFileProductImages" runat="server" Text="Subir Foto">
                                            <DirectEvents>
                                                <Click OnEvent="UploadClickProductImages" Before="if (!#{pnlProductImages}.getForm().isValid()) { return false; } 
                                                            Ext.Msg.wait('Cargando Imagen...', 'Cargando');"
                                                    Failure="Ext.Msg.show({ 
                                                            title   : 'Error', 
                                                            msg     : 'Error during uploading', 
                                                            minWidth: 200, 
                                                            modal   : true, 
                                                            icon    : Ext.Msg.ERROR, 
                                                            buttons : Ext.Msg.OK 
                                                        });">
                                                    <ExtraParams>
                                                        <ext:Parameter Name="id" Value="#{IdProduct}.getValue()" Mode="Raw" />
                                                    </ExtraParams>
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                        <ext:DisplayField ID="dpfImageSizeCat" runat="server" LabelAlign="Right" />
                                    </Items>
                                </ext:FieldContainer>
                                <ext:FieldContainer ID="fieldcontainer6" runat="server">
                                    <Items>
                                        <ext:GridPanel ID="gridProductImages" runat="server" ClientIDMode="Static" AutoScroll="true"
                                            AutoHeight="true" Border="true">
                                            <Store>
                                                <ext:Store ID="storeProductImages" runat="server" FilterOnLoad="false">
                                                    <Model>
                                                        <ext:Model ID="Model7" runat="server" IDProperty="Id">
                                                            <Fields>
                                                                <ext:ModelField Name="Id" />
                                                                <ext:ModelField Name="iorder" />
                                                                <ext:ModelField Name="url" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                            <ColumnModel>
                                                <Columns>
                                                    <ext:TemplateColumn ID="TemplateColumn3" runat="server" Text="Imagen" Flex="15" DataIndex="url"
                                                        TemplateString='<img style="width:60px;height:45px;" src="{url}" />' />
                                                    <ext:Column ID="Column11" runat="server" Text="Id" Flex="35" DataIndex="Id" />
                                                    <ext:Column ID="Column12" runat="server" Text="Orden" Flex="35" DataIndex="iorder" />
                                                </Columns>
                                            </ColumnModel>
                                            <Features>
                                                <ext:GridFilters Enabled="false">
                                                </ext:GridFilters>
                                            </Features>
                                            <View>
                                                <ext:GridView ID="GridView4" runat="server" EmptyText="No Images to Display" />
                                            </View>
                                            <SelectionModel>
                                                <ext:RowSelectionModel ID="RowSelectionModelProductImages" runat="server" Mode="Single" />
                                            </SelectionModel>
                                            <Buttons>
                                                <ext:Button ID="btnDeleteProductImages" runat="server" Text="Eliminar">
                                                    <DirectEvents>
                                                        <Click OnEvent="btnDeleteProductImages_Click">
                                                            <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{ProductDetailsWindow}.body}" />
                                                            <ExtraParams>
                                                                <ext:Parameter Name="id" Value="#{IdProduct}.getValue()" Mode="Raw" />
                                                                <ext:Parameter Name="idValues" Value="Ext.encode(#{gridProductImages}.getRowsValues({selectedOnly : true}))"
                                                                    Mode="Raw" />
                                                            </ExtraParams>
                                                        </Click>
                                                    </DirectEvents>
                                                </ext:Button>
                                            </Buttons>
                                        </ext:GridPanel>
                                    </Items>
                                </ext:FieldContainer>
                            </Items>
                        </ext:FieldSet>
                    </Items>
                </ext:FormPanel>
            </Items>
        </ext:TabPanel>
    </Items>
    <Buttons>
        <ext:Button ID="CancelButton" runat="server" Text="Cancel" Icon="Cancel">
            <Listeners>
                <Click Handler="this.up('window').hide();" />
            </Listeners>
        </ext:Button>
    </Buttons>
</ext:Window>
